<script type="text/javascript" src="report/scripts/js/pstat.js"></script>
<div class="search_box">

<form id="stat_search_form" method="get" action="?do=<?php echo $this->getVar('action'); ?>&query=<?php echo urlencode($output['qs']); ?>">
<input type="hidden" name="do" value="<?php echo $this->getVar('action'); ?>" />
	<div class="search_date_option_box">
		<span class="title">选择时段:</span>
		<?php foreach ($output['search_date_option'] as $itemValue => $itemLabel): ?>
				<?php if (strlen($itemLabel)): ?>
					<label><input type="radio" id="query_date_<?php echo $itemValue; ?>" name="query_date" value="<?php echo $itemValue; ?>" <?php echo (isset($query['query_date']) && (int)$query['query_date'] === (int)$itemValue ? 'checked' : ''); ?> /> <?php echo $itemLabel; ?></label> 
					<?php if ((int)$itemValue === 3): ?>
						<input type="text" id="query_date_calendar" name="query_date_calendar" value="<?php echo isset($query['query_date_calendar']) ? $query['query_date_calendar'] : ''; ?>" readonly="readonly" />
					<?php elseif ((int)$itemValue === 7): ?>
						<select id="query_date_year" name="query_date_year">
							<?php foreach ($output['ym']['query_date_year_option'] as $itemValue => $itemLabel): ?>
								<?php if (isset($query['query_date_year']) && (int)$query['query_date_year'] === (int)$itemValue) : ?>
									<option value="<?php echo $itemValue; ?>" selected><?php echo $itemLabel; ?></option>
								<?php else: ?>
									<option value="<?php echo $itemValue; ?>"><?php echo $itemLabel; ?></option>
								<?php endif; ?>
							<?php endforeach; ?>
						</select>
						<select id="query_date_month" name="query_date_month">
							<?php foreach ($output['ym']['query_date_month_option'] as $itemValue => $itemLabel): ?>
								<option value="<?php echo $itemValue; ?>" <?php echo isset($query['query_date_month']) && (int)$query['query_date_month'] === (int)$itemValue ? 'selected' : ''; ?>><?php echo $itemLabel; ?></option>
							<?php endforeach; ?>
						</select>
					<?php else: ?>
						<?php continue; ?>
					<?php endif; ?>
				<?php endif; ?>
		<?php endforeach; ?>
		  <input type="button" value="查询" name="btn_query" id="btn_query" />
	</div>
	<div class="serach_date_display">
		<div class="title">统计时段:&nbsp;&nbsp;<span><?php echo isset($output['stat_time_text']) ? $output['stat_time_text'] : '--'; ?></span>&nbsp;
		<?php if (isset($query['from']) && in_array((int)$query['from'], array(2, 3))): ?>
			<span>
				<a href="?<?php echo isset($output['qs']) ? $output['qs'] : ''; ?>">←返回</a>
			</span>
		<?php endif; ?>
		</div>
		<?php if(isset($query['search_status'])): ?>
		<div class="title">发送结果:&nbsp;
			<span><?php echo $this->getSendResult($query['search_status'], true); ?></span>
		</div>
		<?php endif; ?>
	</div>
	<!-- 产品搜索选项 start -->
<?php if (!isset($output['showTypes'])): ?>
	<?php if (is_array($output['prods']) && !empty($output['prods'])): ?>
		<div class="search_prod_link_box">
		<?php foreach ($output['prods'] as $prods): ?>
			<?php $prod = intval(isset($query['prod']) ? $query['prod'] : (isset($query['search_prod']) ? $query['search_prod'] : 0)); ?>
			<?php if ((int)$prods['prod'] === $prod): ?>
				<span class="link_selected"><?php echo $prods['name']; ?></span> |
			<?php else: ?>
				<?php $prodQuery = $output['query']; ?>
				<?php if(isset($query['from']) && in_array((int)$query['from'], array(2, 3)) && isset($query['search_prod'])): ?>
					<?php $prodQuery['search_prod'] = $prods['prod']; ?>
						<a href="?do=<?php echo $this->getVar('action') . '&' . http_build_query($prodQuery) . '&qs=' . urlencode($output['qs']); ?>"><?php echo $prods['name']; ?></a> |
				<?php else: ?>
					<?php $prodQuery['prod'] = $prods['prod']; ?>
					<a href="?do=<?php echo $this->getVar('action') . '&' . http_build_query($prodQuery); ?>"><?php echo $prods['name']; ?></a> |
				<?php endif; ?>
			<?php endif; ?>
		<?php endforeach; ?>
		</div>
	<?php endif; ?>
<?php endif; ?>
	<!-- 产品搜索选项 end -->
	<!-- showType选项 start -->
	<?php if (isset($output['showTypes']) && is_array($output['showTypes']) && !empty($output['showTypes'])): ?>
		<div class="search_prod_link_box">
			<span class="title" style="padding-left:0">显示方式:</span>
		<?php foreach ($output['showTypes'] as $showTypeVal => $showTypeLabel): ?>
			<?php $showType = trim(isset($query['show_type']) ? $query['show_type'] : (isset($query['search_show_type']) ? $query['search_show_type'] : null)); ?>
			<?php if ($showTypeVal === $showType): ?>
				<span class="link_selected"><?php echo $showTypeLabel; ?></span> |
			<?php else: ?>
				<?php $showTypeQuery = $output['query']; ?>
				<?php if(isset($query['from']) && in_array((int)$query['from'], array(2, 3)) && isset($query['search_showType'])): ?>
					<?php $showTypeQuery['search_show_type'] = $showTypeVal; ?>
						<a href="?do=<?php echo $this->getVar('action') . '&' . http_build_query($showTypeQuery) . '&qs=' . urlencode($output['qs']); ?>"><?php echo $showTypeLabel; ?></a> |
				<?php else: ?>
					<?php $showTypeQuery['show_type']= $showTypeVal; ?>
					<a href="?do=<?php echo $this->getVar('action') . '&' . http_build_query($showTypeQuery); ?>"><?php echo $showTypeLabel; ?></a> |
				<?php endif; ?>
			<?php endif; ?>
		<?php endforeach; ?>
		</div>
	<?php endif; ?>
	<!-- showType选项 end -->
	<!-- host搜索选项 start -->
	<?php if (isset($output['hosts']) && is_array($output['hosts']) && !empty($output['hosts'])): ?>
		<div class="search_prod_link_box">
		<?php foreach ($output['hosts'] as $hostVal => $hostLabel): ?>
			<?php $host = trim(isset($query['host']) ? $query['host'] : (isset($query['search_host']) ? $query['search_host'] : '')); ?>
			<?php if ($hostVal === $host): ?>
				<span class="link_selected"><?php echo $hostLabel; ?></span> |
			<?php else: ?>
				<?php $hostQuery = $output['query']; ?>
				<?php if(isset($query['from']) && in_array((int)$query['from'], array(2, 3)) && isset($query['search_host'])): ?>
					<?php $hostQuery['search_host'] = $hostVal; ?>
						<a href="?do=<?php echo $this->getVar('action') . '&' . http_build_query($hostQuery) . '&qs=' . urlencode($output['qs']); ?>"><?php echo $hostLabel; ?></a> |
				<?php else: ?>
					<?php $hostQuery['host']= $hostVal; ?>
					<a href="?do=<?php echo $this->getVar('action') . '&' . http_build_query($hostQuery); ?>"><?php echo $hostLabel; ?></a> |
				<?php endif; ?>
			<?php endif; ?>
		<?php endforeach; ?>
		</div>
	<?php endif; ?>
	<!-- host搜索选项 end -->
</form>
</div>